it wat the first time i use the [code] so i think the [ wast just an example because html tags are like this <tag> so here is the same message but with the right tags
Hi all, i hope you can help me understand why this acts like this, im putting here just one function but if you want to see the full file is here http://www10.brinkster.com/jmzl666/nodes.txt (is a txt just rename it to .c). first of all im working with turbo c++ 3 (i know is old but i cant afford a new compiler) and windows xp pro, wel, the problem is that i have a structure like this
Code:
struct node{
int info;
struct node *next;
};
typedef struct node *nodoaptr;
//decalre this inside the main
nodoaptr p=NULL;
I try to make a list using malloc, everything works fine but i have a question (silly if you want), as you see the nodoaptr type is a pointer, so i supose it can be modified enywhere, but it doesnt, here is the original function to create a node (basic version)
Code:
void insnodo(nodoaptr *plist,int x)
{
nodoaptr q,w;
//creat node using malloc
w=getnodo();
clrscr();
if(!w)
{
gotoxy(15,14);
printf("Cant create new node");
getch();
}
else
{
w->info=x;
w->next=NULL;
if(*plist==NULL)
*plist=w;
else
{
for(q=*plist;q->next!=NULL;q=q->next);
q->next=w;
}
}
}
as you can see i use a ** in the funcion (nodoaptr is apointer and i use nodoaptr *list) and then i only use the reference for the value of list, and works great, but if i change the prototype to void (nodoaptr list,int x) and use list instead of *list inside the function everytime the function ends the value of list is never changed, i can understand this if we were talking about regular variables but nodoaptr is a pointer itself, so why it doesnt change the value?, thanks so much in advanced.
Juan Zamudio